Use the following command to create a directory structure under ~/rpmbuild
3. rpmdev-buildtree
The directory structure will contain these 5 folders:
BUILD. BUILD is used as scratch space to actually compile the software.
RPMS. RPMS contains the binary RPM that rpmbuild builds.
SOURCES: Contains the packages source tar ball.
SPECS. SPECS contains your spec file or files—one spec file per RPM you want to build.
SRPMS. SRPMS contains the source RPM built during the process.
This command will also create a sample SPEC file located in ~/rpmbuild/SPECS/<appname>.spec.
Sample SPEC File
Summary: <Discription of package> Name: <Name of package> Version: <Version of package> Release: <Package release number> Copyright: <Copyright Information> Group: <defines how the packaged software should be grouped with other packages> Source: <Location of package source files> URL: <Location of package documentation> Distribution: <contains the name of the product which the packaged software is a part of> Vendor: <Package vendor> Packager: <Name of who packaged this>
%description
<Brief description of the application>
The spec file will detail the neccessary information on how to build the package. Once the spec file is complete you can run the following command()s to build the package:
Build package with Source and Binary RPMs
rpmbuild -ba <appname>.spec
Build package with Source RPMs
rpmbuild -bs <appname>.spec
Source RPMs are stored here: ~/rpmbuild/SRPMS
Binary RPMs are stored here: ~/rpmbuild/RPMS/
Testing RPMS Using rpmlint
1. # cd ~/rpmbuild/SPECS 2. # rpmlint <appname>.spec ../RPMS/*/NAME*.rpm ../SRPMS/NAME*.
Rpmlint will tell you if there are warnings and/or errors with the spec file. The following link will detail common rpmlint errors and warnings that I have encountered and their solutions. rpmlint errors
Once you can run rpmlint with zero errors you are ready to test your package in mock.
How to Build an RPM from source code
Download and unpack the source package
1. wget <link to RPM source code>
2. untar -xvzf hello-2.7.tar.gz
Use the following command to create a directory structure under ~/rpmbuild
3. rpmdev-buildtree
The directory structure will contain these 5 folders:
This command will also create a sample SPEC file located in ~/rpmbuild/SPECS/<appname>.spec.
Sample SPEC File
Summary: <Discription of package>
Name: <Name of package>
Version: <Version of package>
Release: <Package release number>
Copyright: <Copyright Information>
Group: <defines how the packaged software should be grouped with other packages>
Source: <Location of package source files>
URL: <Location of package documentation>
Distribution: <contains the name of the product which the packaged software is a part of>
Vendor: <Package vendor>
Packager: <Name of who packaged this>
%description
<Brief description of the application>
The spec file will detail the neccessary information on how to build the package. Once the spec file is complete you can run the following command()s to build the package:
Build package with Source and Binary RPMs
rpmbuild -ba <appname>.spec
Build package with Source RPMs
rpmbuild -bs <appname>.spec
Source RPMs are stored here: ~/rpmbuild/SRPMS
Binary RPMs are stored here: ~/rpmbuild/RPMS/
Testing RPMS Using rpmlint
1. # cd ~/rpmbuild/SPECS
2. # rpmlint <appname>.spec ../RPMS/*/NAME*.rpm ../SRPMS/NAME*.
Rpmlint will tell you if there are warnings and/or errors with the spec file. The following link will detail common rpmlint errors and warnings that I have encountered and their solutions.
rpmlint errors
Once you can run rpmlint with zero errors you are ready to test your package in mock.